package com.bqtv.sport.ui.mine

import android.content.Context
import android.content.Intent
import android.view.View
import com.bqtv.sport.app.AppActivity
import com.bqtv.sport.databinding.ActivityGoodsDetailBinding
import com.bqtv.sport.dialog.SelectAddressDialog
import com.bqtv.sport.dialog.SetGoodsRemarkDialog

class GoodsDetailActivity : AppActivity<ActivityGoodsDetailBinding>() {
    companion object {
        fun start(context: Context) {
            val intent = Intent(context, GoodsDetailActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun getViewBinding() = ActivityGoodsDetailBinding.inflate(layoutInflater)

    override fun initView() {

    }

    override fun initData() {


        initListener()
    }

    private fun initListener() {
        binding.llAddAddress.setOnClickListener(this)
        binding.tvRemark.setOnClickListener(this)
        binding.tvExchange.setOnClickListener(this)
    }

    override fun onClick(view: View) {
        super.onClick(view)
        when (view) {
            binding.llAddAddress -> {
                val picDialog = SelectAddressDialog.Builder(getContext())
                picDialog.clickResult = object : SelectAddressDialog.Builder.ClickResult {
                    override fun onAddClick() {
                        addAddress()
                    }

                    override fun onItemClick() {

                    }


                }
                picDialog.show()
            }
            binding.tvRemark -> {
                val remarkDialog = SetGoodsRemarkDialog.Builder(getContext())
                remarkDialog.clickResult = object : SetGoodsRemarkDialog.Builder.ClickResult {
                    override fun onAddClick(string: String) {

                    }
                }
                remarkDialog.show()
            }
            binding.tvExchange -> {
                finish()
                ExchangeSuccessActivity.start(getContext())
            }

        }
    }

    private fun addAddress() {
        AddAddressActivity.start(getContext())
    }
}